import React, { forwardRef } from 'react';
import _ from 'lodash';
import classnames from 'classnames';

import preClassName from '../../../../utils/preClassName';

import './style.sass';

import { ChartLegendOption } from '../interface';

interface Iprops {
  legend: ChartLegendOption;
  style?: React.CSSProperties;
}

export default forwardRef<any, Iprops>(({ legend, ...props }, ref) => {
  if (_.isArray(legend)) {
  }

  const isShowLegend = _.get(legend, 'show', false);
  const position = _.get(legend, 'position', 'top');

  return (
    <div
      ref={ref}
      className={classnames(preClassName('legend'), position)}
      style={{ display: isShowLegend ? 'block' : 'none', height: 30, ...props.style }}
    >
      我是图表图例
    </div>
  );
});
